package com.allianz.webapps.controllers;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.allianz.webapps.https.interfaces.type001.pojo.User;
import com.allianz.webapps.https.interfaces.type002.pojo.AppCreateRequset;
import com.allianz.webapps.https.interfaces.util.ObjectUtil;
import com.fasterxml.jackson.databind.ObjectMapper;

@Controller
@RequestMapping("main")
public class AppCreateWithRidersController {
	@Autowired
	private ObjectMapper objectMapper;
	@Autowired
	private ObjectUtil objectUtil;
	/**
	 * 创建订单，同时添加号附加险
	 */
	@RequestMapping("appCreateWithRiders")
	@ResponseBody
	public String appCreateWithRiders (@RequestParam(value="jsonParam") String jsonParam,HttpServletRequest request,HttpServletResponse response) throws Exception{
		AppCreateRequset obj=objectMapper.readValue(jsonParam,AppCreateRequset.class);
		User user=(User)request.getSession().getAttribute("username");
		obj.setUser(user);
		String body=objectUtil.requestParam(obj, "app.createWithRiders");
		return body;
	}
}
